package com.jfinal.weixin.sdk.jfinal;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.Cookie;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.kit.PropKit;
import com.jfinal.weixin.sdk.api.SnsAccessTokenApi;
import com.jfinal.weixin.sdk.kit.PaymentKit;

public class PathInterceptor implements Interceptor {

	public void intercept(Invocation ai) {
Controller controller = ai.getController();
		
		// 设置公共属性
		String cpath = controller.getRequest().getContextPath();

		String basePath = controller.getRequest().getScheme()+"://"+controller.getRequest().getServerName()+":"+controller.getRequest().getServerPort()+cpath;
		controller.setAttr("base", basePath);
		try {
			controller.getRequest().setCharacterEncoding("UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		controller.getResponse().setContentType("text/html; charset="+ "UTF-8");
		ai.invoke();

	}

}
